package csc309.datingapp;

import java.sql.*;
 


public class Trivial{
  
//	public Vector students = new Vector();
//	
//	public Enumeration getStudents() { return students.elements(); }

	public String errormsg;
	
	public String getErrormsg() { return errormsg; }
	public void setErrormsg(String error) { this.errormsg = error; }

	
	
	public String execute() { 
		
    Connection con;  
    try { 
        String username = "group09";
        String password = "asdasdqr3ggqq";
        
        
      Class.forName("com.mysql.jdbc.Driver"); 
      //String url = "jdbc:mysql://sysweb.cs.toronto.edu/csc309?" + "user=csc309&password=summer2009";
      con = DriverManager.getConnection("jdbc:mysql://bungle07.cs.toronto.edu",username, password);

      Statement sql = con.createStatement();

     // String query="select * from students";    
      //ResultSet rs = stmt.executeQuery(query);
      
      ResultSet results = sql.executeQuery("select * from group09.users ");
      if (results != null) {
          while (results.next()) {
            //System.out.println( results.getInt("id") );
        	 id = results.getString("email") ;
        	 
        	    return "success";
          }  
        }    
      
      
      //while(results.next()) 
    	//students.add(new Student(rs.getInt("id"), rs.getString("name")));  
      
    	  results.close();
      	sql.close();
      	con.close();

    } catch(Exception e) {
    	setErrormsg(e.getMessage());
    	return "exception";
    }
    
    return "success";
    
  }
	
	String id ;
	 
      
	
	public void setId(String  id){
	    this.id =id ;
	  }

	  public String getId(){
	    return id;
	  }
	  
	  
	
}
